/**
 * @param {number[]} nums
 * @return {number[][]}
 */
var findSubsequences = function (nums) {
    let res = []
    findSubsequencesLevel(nums, res, [], 0)
    return res
};

function findSubsequencesLevel(nums, res, valArr, index) {
    if (valArr.length >= 2) {
        res.push([...valArr])
    }
    if (index > nums.length) {
        return
    }

    // 本层是否使用过，或者使用数组进行记录。因为不能对数组进行排序，所以只能用list记录
    let levelSet = new Set()
    for (let i = index; i < nums.length; i++) {
        if (levelSet.has(nums[i]) || nums[i] < valArr[valArr.length - 1]) {
            continue
        }
        levelSet.add(nums[i])
        valArr.push(nums[i])
        findSubsequencesLevel(nums, res, valArr, i + 1)
        valArr.pop()
    }
}

// 输入：nums = [4,6,7,7]
// 输出：[[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]